1. Technical Field
The present invention relates to computational method and apparatus in general, and in particular to a method and apparatus for providing a base-2 logarithm approximation to a binary number.
2. Description of Related Art
The logarithm of a binary number can be represented by an integer portion (sometimes called the characteristic) and a fractional portion. For a binary number, the integer portion of a base-2 logarithm is equal to the number of bits after the most significant bit of the binary number. For example, for a binary number 0001 1111 1111 0000, there are 12 bits after the most significant bit; thus, the integer portion of the base-2 logarithm is 12 in decimal or 1100 in binary.
Since the integer portion of the base-2 logarithm of a binary number can be easily defined, a barrel shifter can be used to obtain the integer portion of the base-2 logarithm of a binary number. However, the fractional portion of the base-2 logarithm of a binary number requires more effort to acquire.
In the prior art, the fractional portion of the base-2 logarithm of a binary number can be estimated by using a multiplier, two adders and a shifter. But the usage of a multiplier can result in additional cycles of processing time, which may not be suitable for many real-time applications.
There are logarithm approximating circuits that do not utilize multipliers; however, those logarithm approximating circuits typically require two relatively large lookup tables, an adder and a subtractor as well as other components that are costly in terms of size. Consequently, it would be desirable to provide an improved apparatus for providing a base-2 logarithm approximation to a binary number. The improved apparatus should occupy a relatively small footprint and should require minimal hardware computation cycles.